package com.ruoyi.zsyh.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zsyh.domain.ZsyhStoreOrder;
import com.ruoyi.zsyh.service.IZsyhStoreOrderService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 店铺预订单Controller
 * 
 * @author yuexl
 * @date 2022-03-02
 */
@Controller
@RequestMapping("/zsyh/storeOrder")
public class ZsyhStoreOrderController extends BaseController
{
    private String prefix = "zsyh/storeOrder";

    @Autowired
    private IZsyhStoreOrderService zsyhStoreOrderService;

    @RequiresPermissions("zsyh:storeOrder:view")
    @GetMapping()
    public String storeOrder()
    {
        return prefix + "/storeOrder";
    }

    /**
     * 查询店铺预订单列表
     */
    @RequiresPermissions("zsyh:storeOrder:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZsyhStoreOrder zsyhStoreOrder)
    {
        startPage();
        List<ZsyhStoreOrder> list = zsyhStoreOrderService.selectZsyhStoreOrderList(zsyhStoreOrder);
        return getDataTable(list);
    }

    /**
     * 导出店铺预订单列表
     */
    @RequiresPermissions("zsyh:storeOrder:export")
    @Log(title = "店铺预订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZsyhStoreOrder zsyhStoreOrder)
    {
        List<ZsyhStoreOrder> list = zsyhStoreOrderService.selectZsyhStoreOrderList(zsyhStoreOrder);
        ExcelUtil<ZsyhStoreOrder> util = new ExcelUtil<ZsyhStoreOrder>(ZsyhStoreOrder.class);
        return util.exportExcel(list, "店铺预订单数据");
    }

    /**
     * 新增店铺预订单
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存店铺预订单
     */
    @RequiresPermissions("zsyh:storeOrder:add")
    @Log(title = "店铺预订单", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZsyhStoreOrder zsyhStoreOrder)
    {
        return toAjax(zsyhStoreOrderService.insertZsyhStoreOrder(zsyhStoreOrder));
    }

    /**
     * 修改店铺预订单
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        ZsyhStoreOrder zsyhStoreOrder = zsyhStoreOrderService.selectZsyhStoreOrderById(id);
        mmap.put("zsyhStoreOrder", zsyhStoreOrder);
        return prefix + "/edit";
    }

    /**
     * 修改保存店铺预订单
     */
    @RequiresPermissions("zsyh:storeOrder:edit")
    @Log(title = "店铺预订单", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZsyhStoreOrder zsyhStoreOrder)
    {
        return toAjax(zsyhStoreOrderService.updateZsyhStoreOrder(zsyhStoreOrder));
    }

    /**
     * 删除店铺预订单
     */
    @RequiresPermissions("zsyh:storeOrder:remove")
    @Log(title = "店铺预订单", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zsyhStoreOrderService.deleteZsyhStoreOrderByIds(ids));
    }
}
